package com.ljfresh.customer.utils.udesk;

import com.alibaba.fastjson.JSON;
import com.ljfresh.customer.pojo.Ticket;
import com.ljfresh.customer.pojo.TicketField;
import com.ljfresh.customer.pojo.WorkOrder;

/**
 * 工单属性装换工具
 * @Author zzx
 */

public class TicketUtil {

    public static WorkOrder ticketToWorkOrder(Ticket ticket){
        WorkOrder workOrder = new WorkOrder();
        TicketField ticketField = JSON.parseObject(ticket.getCustom_fields(), TicketField.class);
        workOrder.setId(ticket.getId());
        workOrder.setCellphone(ticket.getUser_cellphone());
        workOrder.setAttachments(ticket.getAttachments());//附件
        workOrder.setStatus(ticket.getStatus());//工单状态
        workOrder.setSubject(ticket.getContent());//udesk的内容 就是自己项目的"主题"  自己项目的"主题"就是udesk端的"内容"
        //workOrder.setVoucher(ticket.getVoucher());//图片凭证
        workOrder.setEmail(ticketField.getTextField_35831());
        workOrder.setStoreId(ticketField.getTextField_35834());
        workOrder.setStoreName(ticketField.getTextField_35836());
        workOrder.setGoodsId(ticketField.getTextField_35775());
        workOrder.setGoodsName(ticketField.getTextField_35835());
        workOrder.setGoodsUnit(ticketField.getTextField_125641());
        workOrder.setPricePerUnit(ticketField.getTextField_125631());
        workOrder.setGoodsNum(ticketField.getTextField_35776());
        workOrder.setRealGoodsNum(ticketField.getTextField_35777());
        workOrder.setArrivalTime(ticketField.getTextField_38627());//到货日期 字符串
        workOrder.setOrderType(ticketField.getSelectField_19468());
        workOrder.setCreateTime(ticketField.getTextField_38643());
        workOrder.setCreator(ticketField.getTextField_50511());
        workOrder.setAttachments(ticket.getAttachments());
        workOrder.setOrder_fid(ticketField.getTextField_131421());
        return workOrder;
    }
}
